package com.framework.auth.api.feign.factory;

import com.framework.auth.api.feign.RemoteAuthService;
import com.framework.common.request.CustomInfoReq;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.security.Principal;

/**
 * @author zhoubb
 * @version V1.0
 * @Date 2020/5/8 21:11
 * @since JDK 1.8
 */
@Slf4j
@Component
public class RemoteAuthFallbackFactory implements FallbackFactory<RemoteAuthService> {
    @Override
    public RemoteAuthService create(Throwable throwable) {
        log.error(throwable.getMessage());
        return new RemoteAuthService() {

            @Override
            public Principal user(Principal principal) {
                return null;
            }

            @Override
            public void refreshTtzAuthentication(CustomInfoReq customInfoReq) {

            }
        };
    }
}
